package com.googlecode.ivybeans.module;

import com.googlecode.ivybeans.module.classpath.ClassPathProviderImpl;
import com.googlecode.ivybeans.module.classpath.ClassPathScope;
import org.netbeans.api.java.classpath.ClassPath;
import org.netbeans.api.java.classpath.GlobalPathRegistry;
import org.netbeans.spi.project.ui.ProjectOpenedHook;

/**
 *
 * @author lforet
 */
public class ProjectOpenedHookImpl extends ProjectOpenedHook {

    private ClassPathProviderImpl cpProvider;

    public ProjectOpenedHookImpl(ClassPathProviderImpl cpProvider) {
        this.cpProvider = cpProvider;
    }
    
    @Override
    protected void projectOpened() {
        GlobalPathRegistry.getDefault().register(ClassPath.COMPILE,
                new ClassPath[]{
                    cpProvider.getClassPath(ClassPathScope.COMPILE),
                    cpProvider.getClassPath(ClassPathScope.COMPILE_TEST)
                });
//      
    }

    @Override
    protected void projectClosed() {
        GlobalPathRegistry.getDefault().unregister(ClassPath.COMPILE,
                new ClassPath[]{
                    cpProvider.getClassPath(ClassPathScope.COMPILE),
                    cpProvider.getClassPath(ClassPathScope.COMPILE_TEST)
                });
    }
}
